package com.iterative.log.web;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.iterative.common.persistence.Page;
import com.iterative.common.persistence.PropertyFilter;
import com.iterative.common.web.BaseController;
import com.iterative.log.entity.Log2Mysql;
import com.iterative.log.service.LogService;
import com.iterative.mysql.entity.MysqlConnect;

/**
 * 日志控制界面
 * @author like
 *
 */
@Controller
@RequestMapping("/log")
public class LogController extends BaseController{
	private static Logger logger = Logger.getLogger(LogController.class);
	
	@Autowired
	private LogService logService;
	
	/**
	 * 默认页面
	 */
	@RequiresPermissions("log:view")
	@RequestMapping(method = RequestMethod.GET)
	public String list() {
		return "log/logList";
	}
	
	/**
	 * 获取所有log日志
	 * @param request
	 * @param response
	 * @return
	 */
	
	@RequestMapping(value="json")
	@ResponseBody
	public Map<String, Object> getLogs(HttpServletRequest request ,HttpServletResponse response){
		Page<Log2Mysql> page = getPage(request);
		List<PropertyFilter> filters = PropertyFilter.buildFromHttpRequest(request);
		page = logService.search(page, filters);
		return getEasyUIData(page);
		
	}
	

}
